﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Db;

namespace Yule8xWxPromotion.XAgent
{
    public partial class RegistList : System.Web.UI.Page
    {
        protected string word;
        protected DataTable dtList;
        protected void Page_Load(object sender, EventArgs e)
        {
            word = RequestUtil.GetString("word", maxLen: 32);
            testLike();
        }
        void testLike()
        {
            // string sqlstmt = "select * from Person.Address where City like '%@add%'";
            string sqlstmt = "select * from t_yx_regist";
            if (word.Length > 0)
            {
                sqlstmt += " where realname like '%'+ @word + '%' or  mobile like '%'+ @word + '%'";
                DbParams dbp = new DbParams(DbFactory.Init(AppInfo.conn_yule8x_agent).ProviderName);
                dbp.AddInputString("@word", word, 16);
                dtList = DbFactory.Init(AppInfo.conn_yule8x_agent).ExecuteDataTable(sqlstmt, dbp.ToArray());
            }else
            {
                dtList = DbFactory.Init(AppInfo.conn_yule8x_agent).ExecuteDataTable(sqlstmt);
            }
        }
        void testIn()
        {
            // string sqlstmt = "select * from Person.Address where AddressID in (@add)";
            string sqlstmt = "exec('select * from t_user where user_id in ('+@ids+')')";
            DbParams dbp = new DbParams(DbFactory.Init(AppInfo.conn_yule8x_agent).ProviderName);
            dbp.AddInputString("@ids", "1001,1002,1006", 16);
            DataTable dt = DbFactory.Init(AppInfo.conn_yule8x_agent).ExecuteDataTable(sqlstmt, dbp.ToArray());
            foreach (DataRow r in dt.Rows)
            {
                Response.Write("<br />" + r["user_id"] + "," + r["nickname"]);
            }

        }
    }
}